//
// RS Game Framework
// Copyright © 2009 Jedd Haberstro
// jhaberstro@gmail.com
// 
// $Id:
//

#include <rs/LockFreeQueue.hpp>
#include <rs/unittest/UnitTest.hpp>

namespace
{
    using namespace rs;
    using namespace rs::unittest;
    
    RS_TEST_CASE(rs::concurrency::LockFreeQueue, SingleThreadedUsage)
    {
        typedef rs::concurrency::LockFreeQueue< int > IntLockFreeQueue;
        IntLockFreeQueue queue;
        for (int i = 0; i < 10; ++i) {
            queue.Push(new IntLockFreeQueue::Cell(i));
        }
        
        RS_ASSERT(queue.GetSize() == 10, "queue's size is incorrect");
        
        for (int i = 0; i < 10; ++i) {
            IntLockFreeQueue::Cell* cell = queue.Pop();
            RS_ASSERT(cell->value == i, "cell's value is incorrect");
            RS_ASSERT(queue.GetSize() == 10 - (i + 1), "queue's size is incorrect");
            delete cell;
        }
    }
}